// 云函数入口文件
const cloud = require('wx-server-sdk')

cloud.init()
const db=cloud.database()
// 云函数入口函数
exports.main = async (event, context) => {
  
 // const about= event.job.about;
  const jobname = event.job.jobname;
  const joblocation = event.job.joblocation;
  const salary = event.job.salary;
  const other = event.job.other;
  const need = event.job.need;
  const desc = event.job.desc;
  const showtime=event.job.showtime;
  const create_time=event.job.create_time;
  const belong=event.job.belong;

  const _id=event._id;
  await db.collection("job_cache").doc(_id).remove()
  return await db.collection("jobs").add({
    data: {
      //about: about,
      jobname: jobname,
      joblocation: joblocation,
      salary: salary,
      other: other,
      need: need,
      desc: desc,
      belong: belong,
      showtime: showtime,
      create_time: create_time
    }
  })
}